package com.pr.makfilm.user.pages.room.create.design;

import com.pr.makfilm.domain.Room;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Pawel
 * Date: 01.10.13
 * Time: 00:24
 * To change this template use File | Settings | File Templates.
 */
public class DesignRowRepeater extends RepeatingView
{
   private List<DesignRow> rows = new ArrayList<DesignRow>();

   public DesignRowRepeater(String id, IModel<Room> model)
   {
      super(id, model);
   }

   @Override
   protected void onPopulate()
   {
      removeAll();
      Room room = (Room) getDefaultModelObject();


      for (int i = 0; i < room.getRowCount(); i++)
      {
         DesignRow row = new DesignRow(newChildId(), getDefaultModel(), i);
         rows.add(row);
         add(row);
      }
   }

   public List<DesignRow> getRows()
   {
      return rows;
   }
}
